<?php

declare (strict_types=1);
namespace App\Models\GameDB\LotteryCrystal;

use App\Models\MainDB\UserData;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
/**
 * @property int $id 
 * @property int $user_id 
 * @property int $level 
 * @property int $balance 
 * @property int $input 
 * @property int $output 
 * @property int $crit_output 
 * @property int $count 
 * @property int $crit_count 
 * @property int $crit_prize_count 
 * @property Carbon $created_at
 * @property Carbon $updated_at
 */
class LotteryCrystalUser extends Model
{
    protected $connection = 'mysql_game';
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'lottery_crystal_user';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    // protected $fillable = [];
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'user_id' => 'integer', 'level' => 'integer', 'balance' => 'integer', 'input' => 'integer', 'output' => 'integer', 'crit_output' => 'integer', 'count' => 'integer', 'crit_count' => 'integer', 'crit_prize_count' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function getDateFormat(): string
    {
        return 'Y-m-d H:i:s.u';
    }

    public function date(): \Illuminate\Database\Eloquent\Relations\HasOne
    {
        return $this->hasOne(LotteryCrystalUserStatDate::class, 'user_id', 'user_id')
            ->withDefault([
                'count' => 0,
                'input' => 0,
                'output' => 0,
            ]);
    }

    public function user(): \Illuminate\Database\Eloquent\Relations\HasOne
    {
        return $this->hasOne(UserData::class, "user_id", "user_id");
    }
}